<template>
  <div class="container">
    <!-- 通过v-for渲染多个单选项 -->
    <div class="option-container" v-for="item in data" :key="item.value" :style="{'display':isHorizontal?'inline-block':'block'}">
      <input type="radio" :disabled=disabled name="hobby" @click="$emit('change', item)" />
      <label>{{ item.label }}</label>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    'data': {
      type: Array,
      default: () => []
    },
    'direction': {
      type: String,
      default: 'horizontal'
    },
    'disabled': {
      type: Boolean,
      default: false
    }
  },
  created() {
  },
  methods: {
  },
  computed: {
    isHorizontal() {
      return this.direction === 'horizontal';
    }
  }
};
</script>

<style lang="scss" scoped>
.option-container {
  margin: 10px 15px;
}
</style>
